package com.lagou.code.controller;

import com.lagou.code.controller.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA by ChouFy on 2020-06-02.
 *
 * @author chouFy
 */
@RestController
@RequestMapping("/com.lagou.code")
public class CodeController {

    @Autowired
    private CodeService codeService;


    @Value("${spring.datasource.driver-class-name}")
    private String name;



    @RequestMapping("/create/{email}")
    public Object create(@PathVariable("email") String email) {
        return codeService.create(email);
    }


    @RequestMapping("/validate/{email}/{code}")
    public Object validate(@PathVariable("email") String email,
                           @PathVariable("code") String code) {

        return codeService.validate(email, code);
    }



    @RequestMapping("")
    public Object Test(){

        return name;
    }
}
